package model

import (
	"encoding/json"
	"github.com/crack007/go-im/src/common/constant"
	"github.com/crack007/go-im/src/common/util"
)

type MessageModel struct {
	MsgId       uint64               `json:"msgId"`
	FromUser    uint32               `json:"fromUser"`
	ToUser      uint32               `json:"toUser"`
	Data        string               `json:"data"`
	FromNode    string               `json:"fromNode"`
	MessageType constant.MessageType `json:"msgType"`
	CreatedAt   string               `json:"createdAt"`
	Action      string               `json:"action"`
}

func NewMessageModel() *MessageModel {
	return &MessageModel{
		CreatedAt: util.GetDatetime(),
	}
}

func (m *MessageModel) String() string {
	data, _ := json.Marshal(m)
	return string(data)
}
